Ext.define('HIT.controller.ImpScheme', {
    extend: 'Ext.app.Controller',
    
    models : [ 'ImpScheme' ],
	stores : [ 'ImpScheme'] ,
    views  : ['SetImpSchemeGrid'],
    onButtonClick: function(button, e, options) {
    	var p;
        var grid=Ext.getCmp('tab-set-impscheme');        
        if (grid == undefined) {
			return;
		}
        if(button.id=='set-main-default'){
        	 var grid=Ext.getCmp('tab-set-impscheme');           
             if (grid == undefined) {
     			return;
     		}
             var selModel = grid.getSelectionModel();
             if (selModel.hasSelection()) {
            	 if (selModel.getCount() != 1) {
            		 Share.ShowMessage("I0009","设置引用");
                     return;
                 }        	
            	Ext.MessageBox.confirm(Share.T('提示'),Share.T('确定设置该引用？'),function(btn){
                   if(btn == 'yes'){                  
        		     var model = selModel.getSelection()[0];	
        		     var schemeId = model.get('scheme_id');
        		     if(model !=undefined){
        		    	 Share.AjaxRequest({
        		    		 url : ctx + '/setQuoteImpscheme',
        		    		 params : {
        		    			 schemeId : schemeId
        		    		 },
        		    		 callback : function(json) {
        		    			 if (json.resultcode == '0') {					
        		    				 grid.getStore().reload();
        		    				 Share.ShowMessage("I0006","设置");
        		    			 }else {
        		    				 Share.ShowMessage("I0007","设置");
        		    			 }
        		    		 },
        		    		 falseFun : function(json) {
        		    			 Share.ShowMessage("I0007","设置");
        		    		 }
        		    	 });
        		     }
                  }
              }); 
            }
        	else{
        		Share.ShowMessage("I0011","需要操作的行");
    			return;
        	}
        }
    		
    },
    init: function(application) {
        this.control({
            "#headpanel button": {
                click: this.onButtonClick
           }
        });
    }
    });